package common.element.column_cast;

import common.element.BytesColumn;
import common.util.Configuration;

import java.io.UnsupportedEncodingException;

/**
 * Created by ibm on 2018/8/17.
 */
class BytesCast
{
    static String encoding = "utf-8";

    static void init(final Configuration configuration)
    {
        BytesCast.encoding = configuration.getString("common.column.encoding",
                BytesCast.encoding);
        return;
    }

    static String asString(final BytesColumn column)
            throws UnsupportedEncodingException
    {
        if (null == column.asBytes())
        {
            return null;
        }

        return new String(column.asBytes(), encoding);
    }
}
